<?php if(!defined('HDPHP_PATH'))exit;C('SHOW_NOTICE',FALSE);?>
<!DOCTYPE HTML>
<html lang="en-US">
<head>
	<meta charset="UTF-8">
	<title></title>
	<script type="text/javascript" src="http://127.0.0.1/c45/c45_classCode/c45Cms/Static/hdjs/jquery-1.7.2.min.js"></script>
	<link type="text/css" rel="stylesheet" href="http://127.0.0.1/c45/c45_classCode/c45Cms/Static/hdjs/hdjs.css"/>
	<script type="text/javascript" src="http://127.0.0.1/c45/c45_classCode/c45Cms/Static/hdjs/hdjs.min.js"></script>
</head>
<body>
	
	<div class="hd-menu-list">
	    <ul>
	        <li class="active"><a href="#">标签列表</a></li>
	        <li><a href="<?php echo U('Tag/add');?>">添加标签</a></li>

	    </ul>
	</div>
	<form action="<?php echo U('Tag/edit');?>" method="post">
		<table class="hd-table hd-table-list">
		    <thead>
		    <tr>
		    	<td>选择</td>
		        <td>TID</td>
		        <td>标签名</td>
		        
		        <td>操作</td>
		    </tr>
		    </thead>
		    
			    <tbody>
			    	        <?php
        //初始化
        $hd['list']['t'] = array(
            'first' => false,
            'last'  => false,
            'total' => 0,
            'index' => 0
        );
        if (empty($tags)) {
            echo '';
        } else {
            $listId = 0;
            $listShowNum=0;
            $listNextId=0;
            foreach ($tags as $t) {
                //开始值
                if ($listId<0) {
                    $listId++;
                    continue;
                }
                //步长
                if($listId!=$listNextId){$listId++;continue;}
                //显示条数
                if($listShowNum>=100)break;
                //第几个值
                $hd['list'][t]['index']++;
                //第1个值
                $hd['list'][t]['first']=($listId == 0);
                //最后一个值
                $hd['list'][t]['last']= (count($tags)-1 <= $listId);
                //总数
                $hd['list'][t]['total']++;
                //增加数
                $listId++;
                $listShowNum++;
                $listNextId+=1
                ?>
					    <tr>
					    	<td  class="hd-w30 tid"><input type="checkbox" name="tid[]" value="<?php echo $t['tid'];?>"></td>
					        <td><?php echo $t['tid'];?></td>
					        <td class="tname">
					            <?php echo $t['tname'];?>
					        </td>
					        
					        <td class="hd-w100">
					            <a href="<?php echo U('Tag/edit');?>">修改</a> |
					            <a href="<?php echo U('Tag/add');?>">添加</a>
					        </td>
					    </tr>
					<?php }}?>
			    </tbody>
		</table>
	<input type="submit" value="修改">
	</form>
	<script type="text/javascript">
		$(function(){
			$('.tid').click(function(){
				chose = $(this).attr('chose');
				// alert(chose);
				if(!chose){
					$(this).attr('chose','1');
					value =$(this).parents('tr').eq(0).find('.tname').html();
					value = value.trim();

					str = "<input type='text' name='tname[]' value='"+value+"' />";

					$(this).parents('tr').eq(0).find('.tname').html(str);
				}else{
					$(this).removeAttr('chose');
					tname = $(this).parents('tr').eq(0).find('.tname').find('input').val();
					$(this).parents('tr').eq(0).find('.tname').html(tname);
				}
				
				
			})
		})
	</script>	
</body>
</html>